package com.jiwei.system.config;


import com.jiwei.system.interceptor.MemberLoginInterceptor;
import com.jiwei.system.interceptor.UserLoginInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptorConfigurer implements WebMvcConfigurer {
    @Bean
    public MemberLoginInterceptor memberLoginInterceptor(){
        return new MemberLoginInterceptor();
    }


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(memberLoginInterceptor())
                .addPathPatterns("/member/**")
                .addPathPatterns("/operator/**")
                .addPathPatterns("/admin/**");

        registry.addInterceptor(new UserLoginInterceptor()).addPathPatterns("/repair/**")
                .excludePathPatterns("/repair/getSMSCode");
    }
}
